#include "junix.h"
#include <grp.h>

int main(int argc, char **argv)
{
	gid_t gid=getgid();
	setbuf(stdout,NULL);
	printf("My gid:    %d\n",gid);

	struct group* gp=getgrgid(gid);
	printf("gr_name:   %s\n",gp->gr_name);
	printf("gr_passwd: %s\n",gp->gr_passwd);
	printf("gr_gid:    %d\n",gp->gr_gid);

	printf("group member:\n");
	char *pm=*gp->gr_mem;
	while(pm)
		printf("%8s ",pm++);

	setgrent();
	while( (gp=getgrent()) != NULL )
	{
		printf("gr_name:   %s\n",gp->gr_name);
		printf("gr_passwd: %s\n",gp->gr_passwd);
		printf("gr_gid:    %d\n\n",gp->gr_gid);
	}
	endgrent();

	return 0;
}

